package com.zyf.school.manager.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zyf.school.manager.domain.Department;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component(value = "departmentDao")
public interface DepartmentDao extends BaseMapper<Department> {

    //查询parent_id为null的数据
    @Select("select * from department where parent_id is null")
    public List<Department> queryParent();

    //通过父类parent_id查询子类
    @Select("select a.* from department a,department b where b.id = #{id} and a.parent_id = b.id")
    public List<Department> queryChildren(int id);
}
